<?php

/**
 * Template engine singleton
 * 
 * The class returns the template engine as singleton object.
 * 
 * @author Oliver Schwarz <oliver.schwarz@gmail.com>
 * @package Core
 */
class TPL
{

        private static $instance;

        private function __construct()
        {
                throw new Exception('TPL: Calling of constructor not allowed');
        }

        public static function getInstance()
        {
                if (!isset(self::$instance)):
                        self::$instance = new Smarty;
                        self::$instance->template_dir = TEMPLATE_DIR;
                        self::$instance->compile_dir = COMPILE_DIR;
                        self::$instance->config_dir = CONFIG_DIR;
                        self::$instance->cache_dir = CACHE_DIR;
                        self::$instance->force_compile = FORCE_COMPILE;
                        self::$instance->assign('app_url', APP_URL);
                        self::$instance->assign('theme_url', TEMPLATE_URL);
                        self::$instance->config_load('en.conf');
                endif;
                return self::$instance;
        }

        public function __clone()
        {
                throw new Exception('TPL: Cloning not allowed');
        }

}

?>